-
Notifications
You must be signed in to change notification settings - Fork 72
update: usage of WP best practices #11137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| * @return string | ||
| */ | ||
| function format_price_helper( array $product, string $currency ): string { | ||
| function wcpay_format_price_helper( array $product, string $currency ): string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Despite this function being inside of a template, it looks like we still need to prefix it with a wcpay_ prefix, otherwise WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound fails
|
|
||
| $wpdb->query( | ||
| $wpdb->prepare( | ||
| "INSERT INTO $this->table (`session_key`, `session_value`, `session_expiry`) VALUES (%s, %s, %d) ON DUPLICATE KEY UPDATE `session_value` = VALUES(`session_value`), `session_expiry` = VALUES(`session_expiry`)", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I just moved the phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared comment before the query. It looks like some linters might fail it.
Test the buildOption 1. Jetpack Beta
Option 2. Jurassic Ninja - available for logged-in A12s🚀 Launch a JN site with this branch 🚀 ℹ️ Install this Tampermonkey script to get more options. Build info:
Note: the build is updated when a new commit is pushed to this PR. |
|
Size Change: 0 B Total Size: 876 kB ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
dmvrtx
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, and thank you for addressing these issues. I have only a pair of nitpicking comments, nothing blocking.
| // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQL.InterpolatedNotPrepared | ||
| $wpdb->query( "DELETE FROM {$wpdb->prefix}wc_admin_notes WHERE name LIKE '{$prefix}%'" ); | ||
| // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared | ||
| $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}wc_admin_note_actions WHERE name LIKE %s", $wpdb->esc_like( self::NOTE_NAME_PREFIX ) . '%' ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In WP 6.2 there is also a %i placeholder for identifiers, and its presence can be checked with wpdb::has_cap( 'identifier_placeholders' ). WooPayments now requires at least WP 6.0, so it's not far from the moment when we can use the %i placeholder unconditionally.
Fixes WOOPMNT-5509
Changes proposed in this Pull Request
Fixing some of the WP plugin best practices.
Testing instructions
Nothing changes here.
npm run changelogto add a changelog file, choosepatchto leave it empty if the change is not significant. You can add multiple changelog files in one PR by running this command a few times.Post merge